#!/bin/bash - 
#===============================================================================
#
#          FILE:  ex15-2.sh
# 
#         USAGE:  ./ex15-2.sh 
# 
#   DESCRIPTION:  printf demo
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: bucunzai (), freecityer@gmail.com
#       COMPANY: FreeCity
#       CREATED: 2011年02月19日 21时20分38秒 CST
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error

declare -r PI=3.1415926535879
declare -r DecimalConstant=31373

Message1="Greetings,"
Message2="Earthling."

echo

printf "Pi to 2 decimal places = %1.2f" $PI
echo
printf "Pi to 9 decimal places = %1.9f" $PI

printf "\n"

printf "Constant = \t%d\n" $DecimalConstant #Inserts tab (\t).

printf "%s %s \n" $Message1 $Message2
echo

pil2=$(printf "%1.12f" $PI)
echo "Pi to 12 decimal places = $pil2" #roundoff error

Msg=`printf "%s %s \n" $Message1 $Message2`
echo $Msg; echo $Msg

exit 0
